<?php
/* ------------------------------------------------------------------------ */
/* Theme's Search Form
/* ------------------------------------------------------------------------ */
global $sd_data;
?>
<script type="text/javascript">
function manageMultipleCategoriesSearch() {
    var selectedCats = "";
    var isFirst = true;
    for (i = 0; i < document.adv_searchform.filterCat.length; i++) {
        if (document.adv_searchform.filterCat[i].selected = true) {
            if (!isFirst)
                selectedCats += ',';
            selectedCats += document.adv_searchform.filterCat[i].value;
            isFirst = false;
        }
    }
    document.adv_searchform.cat.value = selectedCats;
    return true;
}
</script>

<div class="search-box five columns alpha omega" <?php if ($sd_data['slider_enable'] == 0) echo 'style="top: 40px;"'; ?>>
	<div class="search-title">
		<h3><?php _e('Search Course', 'framework'); ?></h3>
	</div>
	<div class="search-form">
	<form id="adv_searchform" action="<?php echo home_url( '/' ); ?>" method="get" name="adv_searchform" onsubmit="return manageMultipleCategoriesSearch()">
		<input id="adv_s" class="input input_large" type="text" name="s" value="<?php _e('Fill your keywords', 'framework'); ?> <?php the_search_query(); ?>" onblur="this.value = this.value || this.defaultValue; this.style.color = '#abaeb4';" onfocus="this.value=''; this.style.color = '#abaeb4';" />
		<select name="filterCat">
			<option  selected="selected" value="-1"><?php echo $sd_data['first_field_title']; ?></option>
			<?php 
	foreach ($sd_data['categories_box_one'] as $cat_id => $cat_value)
		echo '<option id="filterCat_'.$cat_id.'" value="' . $cat_id . '">' .get_the_category_by_id($cat_id). '</option>';
?>
		</select>
		<select name="filterCat">
			<option  selected="selected" value="-1"><?php echo $sd_data['second_field_title']; ?></option>
			<?php 
	foreach ($sd_data['categories_box_two'] as $cat_id => $cat_value)
		echo '<option id="filterCat_'.$cat_id.'" value="' . $cat_id . '">' .get_the_category_by_id($cat_id). '</option>';
?>
		</select>
		<select name="filterCat">
			<option  selected="selected" value="-1"><?php echo $sd_data['third_field_title']; ?></option>
			<?php 
	foreach ($sd_data['categories_box_three'] as $cat_id => $cat_value)
		echo '<option id="filterCat_'.$cat_id.'" value="' . $cat_id . '">' .get_the_category_by_id($cat_id). '</option>';
?>
		</select>
		<input type="hidden" name="cat" value="" />
		<input class="search-submit" type="submit" name="Search" value="Search" />
	</form>
	</div>
</div>
